package main

import (
	"fmt"
	"im/rabbitmq"
	"time"
)

func main() {

	rabbitmq.RabbitPoolServe = &rabbitmq.RabbitPool{
		AMQPURL:       "amqp://guest:guest@localhost:5672/",
		ConnectionNum: 50,
		ChannelNum:    10,
	}
	rabbitmq.RabbitPoolServe.InitRabbit()
	for  {
		pools := make([]*rabbitmq.Pool, 500)
		for i:=0; i<500; i++ {
			pool,err := rabbitmq.RabbitPoolServe.GetPool()
			if err != nil {
				fmt.Println("error: ",err.Error())
				return
			}
			pool.CreateExTopic("msg","point")
			pool.CreateQueuen("point")
			pools[i] = pool
		}
		for _,v := range pools {
		// pool,err := rabbitmq.RabbitPoolServe.GetPool()
		// if err != nil {
		// 	fmt.Println(err.Error())
		// 	return
		// }
		// pool.CreateExTopic("msg","point")
		// pool.CreateQueuen("point")
			err := v.PublicMSg( time.Now().Format("2006-01-02 15:04:05"), rabbitmq.RabbitPoolServe)
			if err != nil {
				fmt.Println("error: ",err.Error())
			}
			fmt.Println("每秒定时输出!", time.Now().Format("2006-01-02 15:04:05"))
		}

		time.Sleep(500 * time.Microsecond)
	}
}
